package com.itheima.service.impl;

import com.itheima.domain.KsClass;
import com.itheima.domain.User;
import com.itheima.mapper.LoginMapper;
import com.itheima.service.LoginService;
import com.itheima.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginMapper loginMapper;

    @Override
    public List<KsClass> selectAndJustRole(String mobile) {
        User user = loginMapper.selectUserByMobile(mobile);
        if (user == null) {
            return null;
        }
        if (user.getRoleId() != 1) {
            return null;
        }
        return loginMapper.seletAllClass();
    }

    @Override
    public boolean login(User user) {
        User account = loginMapper.selectUserByMobileAndPassword(user);
        if (account == null) {
            return false;
        } else {
            return true;
        }
    }
}
